<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "adodb" . EW_PATH_DELIMITER . "adodb.inc.php" ?>
<?php include "phpfn7.php" ?>
<?php include "recibosinfo.php" ?>
<?php include "usuariosinfo.php" ?>
<?php include "cuotasCreditoinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$recibos_edit = new crecibos_edit();
$Page =& $recibos_edit;

// Page init
$recibos_edit->Page_Init();

// Page main
$recibos_edit->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--

// Create page object
var recibos_edit = new ew_Page("recibos_edit");

// page properties
recibos_edit.PageID = "edit"; // page ID
recibos_edit.FormID = "frecibosedit"; // form ID
var EW_PAGE_ID = recibos_edit.PageID; // for backward compatibility

// extend page with ValidateForm function
recibos_edit.ValidateForm = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_credito"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($recibos->credito->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_cuota"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($recibos->cuota->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_punitorios"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($recibos->punitorios->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_pagado"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($recibos->pagado->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_usuario"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($recibos->usuario->FldErrMsg()) ?>");

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}

// extend page with Form_CustomValidate function
recibos_edit.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
recibos_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
recibos_edit.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker"><?php echo $Language->Phrase("Edit") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $recibos->TableCaption() ?><br><br>
<a href="<?php echo $recibos->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$recibos_edit->ShowMessage();
?>
<form name="frecibosedit" id="frecibosedit" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return recibos_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="recibos">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($recibos->Id->Visible) { // Id ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->Id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $recibos->Id->CellAttributes() ?>><span id="el_Id">
<div<?php echo $recibos->Id->ViewAttributes() ?>><?php echo $recibos->Id->EditValue ?></div><input type="hidden" name="x_Id" id="x_Id" value="<?php echo ew_HtmlEncode($recibos->Id->CurrentValue) ?>">
</span><?php echo $recibos->Id->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($recibos->credito->Visible) { // credito ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->credito->FldCaption() ?></td>
		<td<?php echo $recibos->credito->CellAttributes() ?>><span id="el_credito">
<?php if ($recibos->credito->getSessionValue() <> "") { ?>
<div<?php echo $recibos->credito->ViewAttributes() ?>><?php echo $recibos->credito->ViewValue ?></div>
<input type="hidden" id="x_credito" name="x_credito" value="<?php echo ew_HtmlEncode($recibos->credito->CurrentValue) ?>">
<?php } else { ?>
<input type="text" name="x_credito" id="x_credito" title="<?php echo $recibos->credito->FldTitle() ?>" size="30" value="<?php echo $recibos->credito->EditValue ?>"<?php echo $recibos->credito->EditAttributes() ?>>
<?php } ?>
</span><?php echo $recibos->credito->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($recibos->cuota->Visible) { // cuota ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->cuota->FldCaption() ?></td>
		<td<?php echo $recibos->cuota->CellAttributes() ?>><span id="el_cuota">
<?php if ($recibos->cuota->getSessionValue() <> "") { ?>
<div<?php echo $recibos->cuota->ViewAttributes() ?>><?php echo $recibos->cuota->ViewValue ?></div>
<input type="hidden" id="x_cuota" name="x_cuota" value="<?php echo ew_HtmlEncode($recibos->cuota->CurrentValue) ?>">
<?php } else { ?>
<input type="text" name="x_cuota" id="x_cuota" title="<?php echo $recibos->cuota->FldTitle() ?>" size="30" value="<?php echo $recibos->cuota->EditValue ?>"<?php echo $recibos->cuota->EditAttributes() ?>>
<?php } ?>
</span><?php echo $recibos->cuota->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($recibos->fecha->Visible) { // fecha ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->fecha->FldCaption() ?></td>
		<td<?php echo $recibos->fecha->CellAttributes() ?>><span id="el_fecha">
<input type="text" name="x_fecha" id="x_fecha" title="<?php echo $recibos->fecha->FldTitle() ?>" size="30" maxlength="10" value="<?php echo $recibos->fecha->EditValue ?>"<?php echo $recibos->fecha->EditAttributes() ?>>
</span><?php echo $recibos->fecha->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($recibos->punitorios->Visible) { // punitorios ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->punitorios->FldCaption() ?></td>
		<td<?php echo $recibos->punitorios->CellAttributes() ?>><span id="el_punitorios">
<input type="text" name="x_punitorios" id="x_punitorios" title="<?php echo $recibos->punitorios->FldTitle() ?>" size="30" value="<?php echo $recibos->punitorios->EditValue ?>"<?php echo $recibos->punitorios->EditAttributes() ?>>
</span><?php echo $recibos->punitorios->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($recibos->pagado->Visible) { // pagado ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->pagado->FldCaption() ?></td>
		<td<?php echo $recibos->pagado->CellAttributes() ?>><span id="el_pagado">
<input type="text" name="x_pagado" id="x_pagado" title="<?php echo $recibos->pagado->FldTitle() ?>" size="30" value="<?php echo $recibos->pagado->EditValue ?>"<?php echo $recibos->pagado->EditAttributes() ?>>
</span><?php echo $recibos->pagado->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($recibos->usuario->Visible) { // usuario ?>
	<tr<?php echo $recibos->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $recibos->usuario->FldCaption() ?></td>
		<td<?php echo $recibos->usuario->CellAttributes() ?>><span id="el_usuario">
<input type="text" name="x_usuario" id="x_usuario" title="<?php echo $recibos->usuario->FldTitle() ?>" size="30" value="<?php echo $recibos->usuario->EditValue ?>"<?php echo $recibos->usuario->EditAttributes() ?>>
</span><?php echo $recibos->usuario->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("EditBtn")) ?>">
</form>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php
$recibos_edit->Page_Terminate();
?>
<?php

//
// Page class
//
class crecibos_edit {

	// Page ID
	var $PageID = 'edit';

	// Table name
	var $TableName = 'recibos';

	// Page object name
	var $PageObjName = 'recibos_edit';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $recibos;
		if ($recibos->UseTokenInUrl) $PageUrl .= "t=" . $recibos->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $recibos;
		if ($recibos->UseTokenInUrl) {
			if ($objForm)
				return ($recibos->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($recibos->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function crecibos_edit() {
		global $conn, $Language;

		// Language object
		$Language = new cLanguage();

		// Table object (recibos)
		$GLOBALS["recibos"] = new crecibos();

		// Table object (usuarios)
		$GLOBALS['usuarios'] = new cusuarios();

		// Table object (cuotasCredito)
		$GLOBALS['cuotasCredito'] = new ccuotasCredito();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'edit', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'recibos', TRUE);

		// Start timer
		$GLOBALS["gsTimer"] = new cTimer();

		// Open connection
		$conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $recibos;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// Create form object
		$objForm = new cFormObj();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $sDbMasterFilter;
	var $sDbDetailFilter;

	// 
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError, $recibos;

		// Load key from QueryString
		if (@$_GET["Id"] <> "")
			$recibos->Id->setQueryStringValue($_GET["Id"]);

		// Set up master detail parameters
		$this->SetUpMasterDetail();
		if (@$_POST["a_edit"] <> "") {
			$recibos->CurrentAction = $_POST["a_edit"]; // Get action code
			$this->LoadFormValues(); // Get form values

			// Validate form
			if (!$this->ValidateForm()) {
				$recibos->CurrentAction = ""; // Form error, reset action
				$this->setMessage($gsFormError);
				$recibos->EventCancelled = TRUE; // Event cancelled
				$this->RestoreFormValues();
			}
		} else {
			$recibos->CurrentAction = "I"; // Default action is display
		}

		// Check if valid key
		if ($recibos->Id->CurrentValue == "")
			$this->Page_Terminate("reciboslist.php"); // Invalid key, return to list
		switch ($recibos->CurrentAction) {
			case "I": // Get a record to display
				if (!$this->LoadRow()) { // Load record based on key
					$this->setMessage($Language->Phrase("NoRecord")); // No record found
					$this->Page_Terminate("reciboslist.php"); // No matching record, return to list
				}
				break;
			Case "U": // Update
				$recibos->SendEmail = TRUE; // Send email on update success
				if ($this->EditRow()) { // Update record based on key
					$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
					$sReturnUrl = $recibos->getReturnUrl();
					$this->Page_Terminate($sReturnUrl); // Return to caller
				} else {
					$recibos->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Restore form values if update failed
				}
		}

		// Render the record
		$recibos->RowType = EW_ROWTYPE_EDIT; // Render as Edit
		$this->RenderRow();
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm, $recibos;

		// Get upload data
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm, $recibos;
		$recibos->Id->setFormValue($objForm->GetValue("x_Id"));
		$recibos->credito->setFormValue($objForm->GetValue("x_credito"));
		$recibos->cuota->setFormValue($objForm->GetValue("x_cuota"));
		$recibos->fecha->setFormValue($objForm->GetValue("x_fecha"));
		$recibos->punitorios->setFormValue($objForm->GetValue("x_punitorios"));
		$recibos->pagado->setFormValue($objForm->GetValue("x_pagado"));
		$recibos->usuario->setFormValue($objForm->GetValue("x_usuario"));
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm, $recibos;
		$this->LoadRow();
		$recibos->Id->CurrentValue = $recibos->Id->FormValue;
		$recibos->credito->CurrentValue = $recibos->credito->FormValue;
		$recibos->cuota->CurrentValue = $recibos->cuota->FormValue;
		$recibos->fecha->CurrentValue = $recibos->fecha->FormValue;
		$recibos->punitorios->CurrentValue = $recibos->punitorios->FormValue;
		$recibos->pagado->CurrentValue = $recibos->pagado->FormValue;
		$recibos->usuario->CurrentValue = $recibos->usuario->FormValue;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $recibos;
		$sFilter = $recibos->KeyFilter();

		// Call Row Selecting event
		$recibos->Row_Selecting($sFilter);

		// Load SQL based on filter
		$recibos->CurrentFilter = $sFilter;
		$sSql = $recibos->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$recibos->Row_Selected($rs);
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $recibos;
		$recibos->Id->setDbValue($rs->fields('Id'));
		$recibos->credito->setDbValue($rs->fields('credito'));
		$recibos->cuota->setDbValue($rs->fields('cuota'));
		$recibos->fecha->setDbValue($rs->fields('fecha'));
		$recibos->punitorios->setDbValue($rs->fields('punitorios'));
		$recibos->pagado->setDbValue($rs->fields('pagado'));
		$recibos->usuario->setDbValue($rs->fields('usuario'));
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language, $recibos;

		// Initialize URLs
		// Call Row_Rendering event

		$recibos->Row_Rendering();

		// Common render codes for all row types
		// Id

		$recibos->Id->CellCssStyle = ""; $recibos->Id->CellCssClass = "";
		$recibos->Id->CellAttrs = array(); $recibos->Id->ViewAttrs = array(); $recibos->Id->EditAttrs = array();

		// credito
		$recibos->credito->CellCssStyle = ""; $recibos->credito->CellCssClass = "";
		$recibos->credito->CellAttrs = array(); $recibos->credito->ViewAttrs = array(); $recibos->credito->EditAttrs = array();

		// cuota
		$recibos->cuota->CellCssStyle = ""; $recibos->cuota->CellCssClass = "";
		$recibos->cuota->CellAttrs = array(); $recibos->cuota->ViewAttrs = array(); $recibos->cuota->EditAttrs = array();

		// fecha
		$recibos->fecha->CellCssStyle = ""; $recibos->fecha->CellCssClass = "";
		$recibos->fecha->CellAttrs = array(); $recibos->fecha->ViewAttrs = array(); $recibos->fecha->EditAttrs = array();

		// punitorios
		$recibos->punitorios->CellCssStyle = ""; $recibos->punitorios->CellCssClass = "";
		$recibos->punitorios->CellAttrs = array(); $recibos->punitorios->ViewAttrs = array(); $recibos->punitorios->EditAttrs = array();

		// pagado
		$recibos->pagado->CellCssStyle = ""; $recibos->pagado->CellCssClass = "";
		$recibos->pagado->CellAttrs = array(); $recibos->pagado->ViewAttrs = array(); $recibos->pagado->EditAttrs = array();

		// usuario
		$recibos->usuario->CellCssStyle = ""; $recibos->usuario->CellCssClass = "";
		$recibos->usuario->CellAttrs = array(); $recibos->usuario->ViewAttrs = array(); $recibos->usuario->EditAttrs = array();
		if ($recibos->RowType == EW_ROWTYPE_VIEW) { // View row

			// Id
			$recibos->Id->ViewValue = $recibos->Id->CurrentValue;
			$recibos->Id->CssStyle = "";
			$recibos->Id->CssClass = "";
			$recibos->Id->ViewCustomAttributes = "";

			// credito
			$recibos->credito->ViewValue = $recibos->credito->CurrentValue;
			$recibos->credito->CssStyle = "";
			$recibos->credito->CssClass = "";
			$recibos->credito->ViewCustomAttributes = "";

			// cuota
			$recibos->cuota->ViewValue = $recibos->cuota->CurrentValue;
			$recibos->cuota->CssStyle = "";
			$recibos->cuota->CssClass = "";
			$recibos->cuota->ViewCustomAttributes = "";

			// fecha
			$recibos->fecha->ViewValue = $recibos->fecha->CurrentValue;
			$recibos->fecha->CssStyle = "";
			$recibos->fecha->CssClass = "";
			$recibos->fecha->ViewCustomAttributes = "";

			// punitorios
			$recibos->punitorios->ViewValue = $recibos->punitorios->CurrentValue;
			$recibos->punitorios->CssStyle = "";
			$recibos->punitorios->CssClass = "";
			$recibos->punitorios->ViewCustomAttributes = "";

			// pagado
			$recibos->pagado->ViewValue = $recibos->pagado->CurrentValue;
			$recibos->pagado->CssStyle = "";
			$recibos->pagado->CssClass = "";
			$recibos->pagado->ViewCustomAttributes = "";

			// usuario
			$recibos->usuario->ViewValue = $recibos->usuario->CurrentValue;
			$recibos->usuario->CssStyle = "";
			$recibos->usuario->CssClass = "";
			$recibos->usuario->ViewCustomAttributes = "";

			// Id
			$recibos->Id->HrefValue = "";
			$recibos->Id->TooltipValue = "";

			// credito
			$recibos->credito->HrefValue = "";
			$recibos->credito->TooltipValue = "";

			// cuota
			$recibos->cuota->HrefValue = "";
			$recibos->cuota->TooltipValue = "";

			// fecha
			$recibos->fecha->HrefValue = "";
			$recibos->fecha->TooltipValue = "";

			// punitorios
			$recibos->punitorios->HrefValue = "";
			$recibos->punitorios->TooltipValue = "";

			// pagado
			$recibos->pagado->HrefValue = "";
			$recibos->pagado->TooltipValue = "";

			// usuario
			$recibos->usuario->HrefValue = "";
			$recibos->usuario->TooltipValue = "";
		} elseif ($recibos->RowType == EW_ROWTYPE_EDIT) { // Edit row

			// Id
			$recibos->Id->EditCustomAttributes = "";
			$recibos->Id->EditValue = $recibos->Id->CurrentValue;
			$recibos->Id->CssStyle = "";
			$recibos->Id->CssClass = "";
			$recibos->Id->ViewCustomAttributes = "";

			// credito
			$recibos->credito->EditCustomAttributes = "";
			if ($recibos->credito->getSessionValue() <> "") {
				$recibos->credito->CurrentValue = $recibos->credito->getSessionValue();
			$recibos->credito->ViewValue = $recibos->credito->CurrentValue;
			$recibos->credito->CssStyle = "";
			$recibos->credito->CssClass = "";
			$recibos->credito->ViewCustomAttributes = "";
			} else {
			$recibos->credito->EditValue = ew_HtmlEncode($recibos->credito->CurrentValue);
			}

			// cuota
			$recibos->cuota->EditCustomAttributes = "";
			if ($recibos->cuota->getSessionValue() <> "") {
				$recibos->cuota->CurrentValue = $recibos->cuota->getSessionValue();
			$recibos->cuota->ViewValue = $recibos->cuota->CurrentValue;
			$recibos->cuota->CssStyle = "";
			$recibos->cuota->CssClass = "";
			$recibos->cuota->ViewCustomAttributes = "";
			} else {
			$recibos->cuota->EditValue = ew_HtmlEncode($recibos->cuota->CurrentValue);
			}

			// fecha
			$recibos->fecha->EditCustomAttributes = "";
			$recibos->fecha->EditValue = ew_HtmlEncode($recibos->fecha->CurrentValue);

			// punitorios
			$recibos->punitorios->EditCustomAttributes = "";
			$recibos->punitorios->EditValue = ew_HtmlEncode($recibos->punitorios->CurrentValue);

			// pagado
			$recibos->pagado->EditCustomAttributes = "";
			$recibos->pagado->EditValue = ew_HtmlEncode($recibos->pagado->CurrentValue);

			// usuario
			$recibos->usuario->EditCustomAttributes = "";
			$recibos->usuario->EditValue = ew_HtmlEncode($recibos->usuario->CurrentValue);

			// Edit refer script
			// Id

			$recibos->Id->HrefValue = "";

			// credito
			$recibos->credito->HrefValue = "";

			// cuota
			$recibos->cuota->HrefValue = "";

			// fecha
			$recibos->fecha->HrefValue = "";

			// punitorios
			$recibos->punitorios->HrefValue = "";

			// pagado
			$recibos->pagado->HrefValue = "";

			// usuario
			$recibos->usuario->HrefValue = "";
		}

		// Call Row Rendered event
		if ($recibos->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$recibos->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError, $recibos;

		// Initialize form error message
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!ew_CheckInteger($recibos->credito->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $recibos->credito->FldErrMsg();
		}
		if (!ew_CheckInteger($recibos->cuota->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $recibos->cuota->FldErrMsg();
		}
		if (!ew_CheckNumber($recibos->punitorios->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $recibos->punitorios->FldErrMsg();
		}
		if (!ew_CheckNumber($recibos->pagado->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $recibos->pagado->FldErrMsg();
		}
		if (!ew_CheckInteger($recibos->usuario->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $recibos->usuario->FldErrMsg();
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $sFormCustomError;
		}
		return $ValidateForm;
	}

	// Update record based on key values
	function EditRow() {
		global $conn, $Security, $Language, $recibos;
		$sFilter = $recibos->KeyFilter();
		$recibos->CurrentFilter = $sFilter;
		$sSql = $recibos->SQL();
		$conn->raiseErrorFn = 'ew_ErrorFn';
		$rs = $conn->Execute($sSql);
		$conn->raiseErrorFn = '';
		if ($rs === FALSE)
			return FALSE;
		if ($rs->EOF) {
			$EditRow = FALSE; // Update Failed
		} else {

			// Save old values
			$rsold =& $rs->fields;
			$rsnew = array();

			// credito
			$recibos->credito->SetDbValueDef($rsnew, $recibos->credito->CurrentValue, NULL, FALSE);

			// cuota
			$recibos->cuota->SetDbValueDef($rsnew, $recibos->cuota->CurrentValue, NULL, FALSE);

			// fecha
			$recibos->fecha->SetDbValueDef($rsnew, $recibos->fecha->CurrentValue, NULL, FALSE);

			// punitorios
			$recibos->punitorios->SetDbValueDef($rsnew, $recibos->punitorios->CurrentValue, NULL, FALSE);

			// pagado
			$recibos->pagado->SetDbValueDef($rsnew, $recibos->pagado->CurrentValue, NULL, FALSE);

			// usuario
			$recibos->usuario->SetDbValueDef($rsnew, $recibos->usuario->CurrentValue, NULL, FALSE);

			// Call Row Updating event
			$bUpdateRow = $recibos->Row_Updating($rsold, $rsnew);
			if ($bUpdateRow) {
				$conn->raiseErrorFn = 'ew_ErrorFn';
				$EditRow = $conn->Execute($recibos->UpdateSQL($rsnew));
				$conn->raiseErrorFn = '';
			} else {
				if ($recibos->CancelMessage <> "") {
					$this->setMessage($recibos->CancelMessage);
					$recibos->CancelMessage = "";
				} else {
					$this->setMessage($Language->Phrase("UpdateCancelled"));
				}
				$EditRow = FALSE;
			}
		}

		// Call Row_Updated event
		if ($EditRow)
			$recibos->Row_Updated($rsold, $rsnew);
		$rs->Close();
		return $EditRow;
	}

	// Set up master/detail based on QueryString
	function SetUpMasterDetail() {
		global $recibos;
		$bValidMaster = FALSE;

		// Get the keys for master table
		if (@$_GET[EW_TABLE_SHOW_MASTER] <> "") {
			$sMasterTblVar = $_GET[EW_TABLE_SHOW_MASTER];
			if ($sMasterTblVar == "") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = "";
				$this->sDbDetailFilter = "";
			}
			if ($sMasterTblVar == "cuotasCredito") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $recibos->SqlMasterFilter_cuotasCredito();
				$this->sDbDetailFilter = $recibos->SqlDetailFilter_cuotasCredito();
				if (@$_GET["cuota"] <> "") {
					$GLOBALS["cuotasCredito"]->cuota->setQueryStringValue($_GET["cuota"]);
					$recibos->cuota->setQueryStringValue($GLOBALS["cuotasCredito"]->cuota->QueryStringValue);
					$recibos->cuota->setSessionValue($recibos->cuota->QueryStringValue);
					if (!is_numeric($GLOBALS["cuotasCredito"]->cuota->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@cuota@", ew_AdjustSql($GLOBALS["cuotasCredito"]->cuota->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@cuota@", ew_AdjustSql($GLOBALS["cuotasCredito"]->cuota->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
				if (@$_GET["creditoId"] <> "") {
					$GLOBALS["cuotasCredito"]->creditoId->setQueryStringValue($_GET["creditoId"]);
					$recibos->credito->setQueryStringValue($GLOBALS["cuotasCredito"]->creditoId->QueryStringValue);
					$recibos->credito->setSessionValue($recibos->credito->QueryStringValue);
					if (!is_numeric($GLOBALS["cuotasCredito"]->creditoId->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@creditoId@", ew_AdjustSql($GLOBALS["cuotasCredito"]->creditoId->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@credito@", ew_AdjustSql($GLOBALS["cuotasCredito"]->creditoId->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
		}
		if ($bValidMaster) {

			// Save current master table
			$recibos->setCurrentMasterTable($sMasterTblVar);

			// Reset start record counter (new master key)
			$this->lStartRec = 1;
			$recibos->setStartRecordNumber($this->lStartRec);
			$recibos->setMasterFilter($this->sDbMasterFilter); // Set up master filter
			$recibos->setDetailFilter($this->sDbDetailFilter); // Set up detail filter

			// Clear previous master key from Session
			if ($sMasterTblVar <> "cuotasCredito") {
				if ($recibos->cuota->QueryStringValue == "") $recibos->cuota->setSessionValue("");
				if ($recibos->credito->QueryStringValue == "") $recibos->credito->setSessionValue("");
			}
		} else {
			$this->sDbMasterFilter = $recibos->getMasterFilter(); //  Restore master filter
			$this->sDbDetailFilter = $recibos->getDetailFilter(); // Restore detail filter
		}
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	function Message_Showing(&$msg) {

		// Example:
		//$msg = "your new message";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>
